<?php
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\captcha\Captcha;
use common\models\articles\Articles;

$this->title = '用户注册';
$this->params['breadcrumbs'][] = $this->title;
$ar = Articles::find()->where(['category_id'=>36])->one();

?>
<section class="formbox">
<form action="<?= yii\helpers\Url::to(['auth/signup']);?>" id="subform" method='post' role="form">

	            <div class="textlines">
					<input name="_csrf" type="hidden" id="_csrf" value="<?= Yii::$app->request->csrfToken ?>">
	            	<ul>
	            		<li><span class="boxtt">账户：</span><input type="text" id="user" name="SignupForm[username]"<?php if(\Yii::$app->getSession()->getFlash("error")) {  ?> value=" <?php echo \Yii::$app->getSession()->getFlash("error");
							?>" style="style="color:red;font-size: 0.26rem;" <?php } ?> placeholder="设置帐户名"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">密码：</span><input type="password" id="pasw"  name="SignupForm[password]" value="" placeholder="设置登录密码，6-32位字符"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">密码：</span><input type="password" id="paswd"  name="SignupForm[repassword]" value="" placeholder="确认登录密码，6-32位字符"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">名称：</span><input type="text" id="name"  name="SignupForm[qiyename]" value="" placeholder="请输入您的企业名称"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">姓名：</span><input type="text" id="xingm" name="SignupForm[xingming]" value="" placeholder="请输入联系人姓名"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">职务：</span><input type="text" id="zhiwu" name="SignupForm[zhiwu]" value="" placeholder="请输入联系人职务"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">手机：</span><input type="text"  id="tel" name="SignupForm[phone]" value="" placeholder="请输入联系人手机号"/><span class="xing">*</span></li>
	            		<li><span class="boxtt">邮箱：</span><input type="text" id="email"  name="SignupForm[email]" value="" placeholder="请输入联系人常用邮箱"/><span class="xing">*</span></li>
	            		
	            		<li><span class="boxtt">验证码：</span><input class="mobiletext" id="pasw" type="text" value="" placeholder="请输入手机验证码"/><input class="yzmbtn" id="btnSendCode" type="button" name="" value="获取验证码" onClick="sendMessage()" /></li>
	            	</ul>
	            </div>
	            <div class="dlrk">已有账号？<a href="/auth/login"><span>请登录</span></a></div>
	            <div class="xyspan"><input class="a" type="checkbox" id="a" />我已经阅读<a href="<?= yii\helpers\Url::to(['content/index', 'id' => 36])?>" target="_blank"><span>《<?=$ar['title'] ?>》</span></div>
	            <div class="submitbtn"><input id="sub" type="submit"  value="注册"/></div>
	            
	
</form>
				<script>
					$(document).ready(function() {
						$("#sub").click(function(){

							var User = $("#user").val();
							var Pasw = $("#pasw").val();
							var Paswd = $("#paswd").val();
							var Name = $("#name").val();
							var Xingm = $("#xingm").val();
							var Zhiwu = $("#zhiwu").val();
							var tel_check  = /^(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
							var email_check  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
							var Yanzheng = $("#yanzheng").val();

							if(User==""){
								alert("请填写用户名！");
								return false;
							}

							if(Pasw==""){
								alert("请填写密码！");
								return false;
							} else {
								if(Pasw.length < 6) {
									alert("密码长度小于6！");
									return false;
								}
							}

							if(Paswd==""){
								alert("请填写确认密码！");
								return false;
							} else {
								if(Paswd != Pasw) {
									alert("两次密码不一致！");
									return false;
								}
							}

							if(Name==""){
								alert("请填写正确的企业名称！");
								return false;
							}

							if(Xingm==""){
								alert("请填写正确的姓名！");
								return false;
							}

							if(Zhiwu==""){
								alert("请填写职务！");
								return false;
							}

							if($("#tel").val()=='' || !tel_check.test($("#tel").val())){
								alert("请填写正确的电话！");
								return false;
							}

							if($("#email").val()=='' || !email_check.test($("#email").val())){
								alert("请填写正确的邮箱！");
								return false;
							}

							if(Yanzheng==""){
								alert("验证码不能为空！");
								return false;
							}
							if($("#a").prop("checked")){

							}else{
								alert("请仔细阅读协议！");
								return false;
							}
							exit();
						})

					});
				</script>

				<script type="text/javascript">
					var InterValObj; //timer变量，控制时间
					var count = 30; //间隔函数，1秒执行
					var curCount;//当前剩余秒数
					var code = ""; //验证码
					var codeLength = 6;//验证码长度
					function sendMessage() {
						curCount = count;
						var dealType; //验证方式
						var uid=$("#uid").val();//用户uid
						if ($("#phone").attr("checked") == true) {
							dealType = "phone";
						}
						else {
							dealType = "email";
						}
//产生验证码
						for (var i = 0; i < codeLength; i++) {
							code += parseInt(Math.random() * 9).toString();
						}
//设置button效果，开始计时
						$("#btnSendCode").attr("disabled", "true");
						$("#btnSendCode").val( + curCount + "秒再获取");
						InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
//向后台发送处理数据
						$.ajax({
							type: "POST", //用POST方式传输
							dataType: "text", //数据格式:JSON
							url: 'Login.ashx', //目标地址
							data: "dealType=" + dealType +"&uid=" + uid + "&code=" + code,
							error: function (XMLHttpRequest, textStatus, errorThrown) { },
							success: function (msg){ }
						});
					}
					//timer处理函数
					function SetRemainTime() {
						if (curCount == 0) {
							window.clearInterval(InterValObj);//停止计时器
							$("#btnSendCode").removeAttr("disabled");//启用按钮
							$("#btnSendCode").val("重新发送验证码");
							code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效
						}
						else {
							curCount--;
							$("#btnSendCode").val( + curCount + "秒再获取");
						}
					}
				</script>
</section>
			
			
            

		

